//
//  CanMoveView.m
//  BigJoy
//
//  Created by Rowling on 2017/6/14.
//  Copyright © 2017年 Rowling. All rights reserved.
//

#import "CanMoveView.h"
#import "DIYDetailViewController.h"

@implementation CanMoveView

-(UIImageView *)makeImageView {
    if (_makeImageView == nil) {
        _makeImageView = [[UIImageView alloc]init];
    }
    return _makeImageView;
}

-(UILabel *)titleLable {
    if (_titleLable == nil) {
        _titleLable = [[UILabel alloc]init];
    }
    return _titleLable;
}

-(instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
        self.backgroundColor = [UIColor whiteColor];
        self.layer.shadowOffset = CGSizeMake(0, 1);
        self.layer.shadowColor = [UIColor blackColor].CGColor;
        self.layer.shadowOpacity = 0.2;
    }
    return self;
}

-(void)setUpUI {
    //titleLabel
    self.titleLable.text = @"T恤";
    self.titleLable.font = [UIFont systemFontOfSize:15];
    [self.titleLable sizeToFit];
    self.titleLable.textAlignment = 1;
    [self addSubview:self.titleLable];
    self.titleLable.centerX = self.frame.size.width / 2;
    self.titleLable.y = 20;
    
    //imageView
    [self addSubview:self.makeImageView];
    self.makeImageView.frame = CGRectMake(0, 0, self.frame.size.width * 0.7, self.frame.size.height * 0.5);
    self.makeImageView.image = [UIImage imageNamed:@"1.jpeg"];
    self.makeImageView.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height/2);

    //button
    self.makeButton = [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 50)];
    [self.makeButton setTitle:@"制作" forState:UIControlStateNormal];
    [self addSubview:self.makeButton];
    self.makeButton.center = CGPointMake(self.frame.size.width / 2, self.frame.size.height - 50);
    [self.makeButton setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    self.makeButton.layer.borderWidth = 1;
    self.makeButton.layer.borderColor = [UIColor blackColor].CGColor;
    [self.makeButton addTarget:self action:@selector(makeButtonClick) forControlEvents:UIControlEventTouchUpInside];
}

-(void)makeButtonClick {
    DIYDetailViewController * vc = [[DIYDetailViewController alloc]init];
    [[XMSuperHelper XMControllerOfView:self].navigationController pushViewController:vc animated:YES];
}

@end
